home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 September / maximum-cd-2000-09.iso / Vampire the Masquerade / vampire_demo.exe / Codex.nob / DoorSwitchPivot.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-22  |  2.4 KB  |  74 lines

  1. public class DoorSwitchPivot extends Codex {
  2.    private float _speed = 10.0F;
  3.    private float _openTime;
  4.    private CodexThing _switchThing;
  5.    private CodexThing door;
  6.    private int doorGuid;
  7.    private boolean bOpen;
  8.    private boolean bActive;
  9.    private boolean bSwitchActive;
  10.    public static String[] _params = new String[]{"Movement speed;150.0", "Switch Time;0", "Switch"};
  11.  
  12.    public void clicked(int guid, int clickerGuid, int captureId) {
  13.       if (!this.bActive && !this.bSwitchActive) {
  14.          if (guid == this.doorGuid) {
  15.             new CodexSound("locked_large_02.WAV", 300.0F, 600.0F, 100, 0, 0, clickerGuid);
  16.             CodexConsole.PrintNLS(clickerGuid, 0, "GEN_OPENELSEWHERE");
  17.          } else {
  18.             this.bActive = true;
  19.             this.bSwitchActive = true;
  20.             if (!this.bOpen) {
  21.                this._switchThing.RotatePivot(1, this._openTime);
  22.                this.door.MoveToFrame(1, this._speed);
  23.                this.bOpen = true;
  24.             } else {
  25.                this._switchThing.RotatePivot(1, -this._openTime);
  26.                this.door.MoveToFrame(0, this._speed);
  27.                this.bOpen = false;
  28.             }
  29.  
  30.          }
  31.       }
  32.    }
  33.  
  34.    public void beginscene(int clientGuid, int captureID) {
  35.       this.door.SetThingFlags(8192);
  36.    }
  37.  
  38.    public void arrived(int thingGuid, int frameNum, int captureId) {
  39.       if (thingGuid == this.door.GetGUID()) {
  40.          this.bActive = false;
  41.       }
  42.  
  43.       if (thingGuid == this._switchThing.GetGUID()) {
  44.          this.bSwitchActive = false;
  45.       }
  46.  
  47.    }
  48.  
  49.    public void restore(int flags) {
  50.       this.bOpen = CodexSequence.RestoreBoolean();
  51.    }
  52.  
  53.    public void save(int flags) {
  54.       CodexSequence.SaveBoolean(this.bOpen);
  55.    }
  56.  
  57.    public DoorSwitchPivot(float speed, float openTime, CodexThing switchThing) {
  58.       this._speed = speed;
  59.       this._openTime = openTime;
  60.       this._switchThing = new CodexThing(((Codex)switchThing).GetGUID());
  61.       ((Codex)this).CaptureThing(this._switchThing.GetGUID());
  62.       this.doorGuid = ((Codex)this).GetClassThing();
  63.       this.door = new CodexThing(this.doorGuid);
  64.       if (this.door.GetDescriptionID().equalsIgnoreCase("PROP")) {
  65.          this.door.SetDescriptionID("GEN_DOOR");
  66.       }
  67.  
  68.       if (this._switchThing.GetDescriptionID().equalsIgnoreCase("PROP")) {
  69.          this._switchThing.SetDescriptionID("GEN_SWITCH");
  70.       }
  71.  
  72.    }
  73. }
  74.